/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainForm.java
 *
 * Created on Oct 26, 2013, 8:30:39 PM
 */
package sims.gui;

import java.awt.Component;
import sims.entity.TbEmployee;

/**
 *
 * @author NINH
 */
public class MainForm extends javax.swing.JFrame {

    /** Creates new form MainForm */
    static MainForm self;
    static String roleName="administrator";
    static TbEmployee emp;

    public MainForm() {
        self = this;
        initComponents();
        setTitle("Inventory managerment");
        setLocationRelativeTo(this);
        setResizable(false);
        HideMenu();
        AddPanelMenu(new AdminMenu());
    }

    public void AddPanelContent(Component panel) {
        jplContent.removeAll();
        panel.setSize(jplContent.getSize());
        jplContent.add(panel);
        jplContent.updateUI();
    }

    public void AddPanelMenu(Component panel) {
        jplMenu.removeAll();
        panel.setSize(jplMenu.getSize());
        jplMenu.add(panel);
        jplMenu.updateUI();
    }

    public void HideMenu() {
        if (roleName != null) {
            if (roleName.equalsIgnoreCase("administrator")) {
                jmnInventoryManager.setVisible(false);
                jmnSaleManager.setVisible(false);
                jmnSalePersion.setVisible(false);
            } else if (roleName.equalsIgnoreCase("sale persion")) {
                jmnAdmin.setVisible(false);
                jmnInventoryManager.setVisible(false);
                jmnSaleManager.setVisible(false);
            } else if (roleName.equalsIgnoreCase("sale manager")) {
                jmnAdmin.setVisible(false);
                jmnInventoryManager.setVisible(false);
                jmnSalePersion.setVisible(false);
            } else if (roleName.equalsIgnoreCase("inventory manager")) {
                jmnAdmin.setVisible(false);
                jmnSaleManager.setVisible(false);
                jmnSalePersion.setVisible(false);
            }
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jplMenu = new javax.swing.JPanel();
        jplContent = new javax.swing.JPanel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();
        jmnAdmin = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem1 = new javax.swing.JMenuItem();
        jmnSalePersion = new javax.swing.JMenu();
        jmnSaleManager = new javax.swing.JMenu();
        jmnInventoryManager = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jplMenu.setPreferredSize(new java.awt.Dimension(1060, 30));

        javax.swing.GroupLayout jplMenuLayout = new javax.swing.GroupLayout(jplMenu);
        jplMenu.setLayout(jplMenuLayout);
        jplMenuLayout.setHorizontalGroup(
            jplMenuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 1046, Short.MAX_VALUE)
        );
        jplMenuLayout.setVerticalGroup(
            jplMenuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 30, Short.MAX_VALUE)
        );

        jplContent.setBackground(new java.awt.Color(255, 255, 255));
        jplContent.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        javax.swing.GroupLayout jplContentLayout = new javax.swing.GroupLayout(jplContent);
        jplContent.setLayout(jplContentLayout);
        jplContentLayout.setHorizontalGroup(
            jplContentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 1042, Short.MAX_VALUE)
        );
        jplContentLayout.setVerticalGroup(
            jplContentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 543, Short.MAX_VALUE)
        );

        jMenu1.setText("File");
        jMenuBar1.add(jMenu1);

        jMenu2.setText("Edit");
        jMenuBar1.add(jMenu2);

        jmnAdmin.setText("Administrator");

        jMenuItem2.setText("Logout");
        jmnAdmin.add(jMenuItem2);

        jMenuItem1.setText("jMenuItem1");
        jmnAdmin.add(jMenuItem1);

        jMenuBar1.add(jmnAdmin);

        jmnSalePersion.setText("Sale persion");
        jMenuBar1.add(jmnSalePersion);

        jmnSaleManager.setText("Sale manager");
        jMenuBar1.add(jmnSaleManager);

        jmnInventoryManager.setText("Inventory manager");
        jMenuBar1.add(jmnInventoryManager);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jplContent, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jplMenu, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 1046, Short.MAX_VALUE))
                .addGap(10, 10, 10))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jplMenu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jplContent, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new MainForm().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenu jmnAdmin;
    private javax.swing.JMenu jmnInventoryManager;
    private javax.swing.JMenu jmnSaleManager;
    private javax.swing.JMenu jmnSalePersion;
    private javax.swing.JPanel jplContent;
    private javax.swing.JPanel jplMenu;
    // End of variables declaration//GEN-END:variables
}
